home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12441 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.1 KB  |  32 lines

  1. Newsgroups: comp.lang.c
  2. Path: nntp.coast.net!torn!sq!msb
  3. From: msb@sq.com (Mark Brader)
  4. Subject: Re: routine for yesterday's date
  5. Message-ID: <1996Mar31.062512.22480@sq.com>
  6. Organization: SoftQuad Inc., Toronto, Canada
  7. References: <315c4d0f.19874776@ottnews.shl.com> <1996Mar30.043002.19054@sq.com> <Dp3B56.FKI@alisa.org>
  8. Date: Sun, 31 Mar 1996 06:25:12 GMT
  9.  
  10. > [Why not]
  11. >     long ticks; struct tm * dt;
  12. >     time(&ticks);
  13. >     ticks -= 86400; /* 86400 seconds in a day */
  14. >     dt = localtime (&ticks);
  15.  
  16. First, this attempts to compute the date 24 hours ago, which may not be
  17. yesterday in the case of daylight saving time transitions.  (It may be
  18. helpful in the future to read the article you're responding to.)
  19.  
  20. Second, long should be time_t.
  21.  
  22. Third, the representation of times and dates within a time_t is not
  23. defined, so the operation of subtracting 86400 does not produce a known
  24. result.  (On UNIX implementations, of course, it does.)
  25.  
  26. *That's* why not.
  27. -- 
  28. Mark Brader, msb@sq.com | "B-b-but laziness is the only virtue I have *left*!"
  29. SoftQuad Inc., Toronto  |                                -- Jutta Degener
  30.  
  31. My text in this article is in the public domain.
  32.